<?php
	$tid = trim($_POST['tid']);
	$tName = trim($_POST['tName']);
	$left = trim($_POST['left']);
	if(!$tid || !$tName || !$left){
		exit('parm is miss !');
	}
	if($tid == 'all'){
		$tName = 'all';
	}
	require '../autoload.php';
	$mp = new MyPdo();
	if($tid == 'all'){
		$sql = "select rights from translate_info where lefts = ?";
		$arr = array($left);
	}else{
		$sql = "select rights from translate_info where typeid = ? and lefts = ?";
		$arr = array($tid,$left);
	}
	$res = $mp->dql($sql,$arr);
	if($res){
		$dir = "../Runtime/CacheRight/{$tName}";
		if(!is_dir($dir)){
			mkdir($dir,0777,true);
		}
		$fileName = $dir.'/'.md5($left);
		$arr = array();
		foreach($res as $v){
			array_push($arr,$v['rights']);
		}
		ob_start();
		echo $res2 = json_encode($arr);
		file_put_contents($fileName,$res2);
	}else{
		echo 'err';
	}
